package com.github.ghsea.scheduler.timer;

import com.google.common.util.concurrent.ThreadFactoryBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.concurrent.ThreadFactory;

/**
 * @author netty
 */
public class ThreadFactoryUtil {

    static final Logger  logger = LoggerFactory.getLogger(ThreadFactoryUtil.class);
    public static ThreadFactory newThreadFactory(String nameFormat) {
        return new ThreadFactoryBuilder()
                .setNameFormat(nameFormat)
                .setDaemon(false)
                .setUncaughtExceptionHandler((t, e) -> logger.error(" createing thread:{} error", t.getName(), e)).build();
    }
}
